﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CMN.BLL;
using CMN.Common;
using CMN.Entity;
using CMN.Models.Interfaces;
namespace CMN.Models
{
    /// <summary>
    /// 专题Service
    /// </summary>
    public class Normal_ZTService: IDataService<Normal_ZTEntity>
    {
        /// <summary>
        /// 新增专题
        /// </summary>
        /// <param name="Normal_ZTEntity"></param>
        /// <returns>string</returns>
        public string Insert(Normal_ZTEntity normal_ztEntity)
        {
            Normal_ZT bll = new Normal_ZT();
            normal_ztEntity.DataTable_Action = DataTableAction.Insert;
            if (bll.InsertUpdateDelete(normal_ztEntity) > 0)
            {
                return "";
            }
            else
            {
                return "失败";
            }
        }

        /// <summary>
        /// 返回专题查询列表
        /// </summary>
        /// <param name="qp"></param>
        /// <param name="count">查询总个数</param>
        /// <returns>List</returns>
        public List<Normal_ZTEntity> List(QueryParam qp,out int count)
        {
            Normal_ZT bll = new Normal_ZT();
            return bll.List(qp, out count);
        }

        /// <summary>
        /// 更新专题
        /// </summary>
        /// <param name="Normal_ZT"></param>
        /// <returns>string</returns>
        public string Update(Normal_ZTEntity normal_ztEntity)
        {
            Normal_ZT bll = new Normal_ZT();
            normal_ztEntity.DataTable_Action = DataTableAction.Update;
            if (bll.InsertUpdateDelete(normal_ztEntity) > 0)
            {
                  return "";
            }
            else
            {
                return "失败";
            }
        }

        /// <summary>
        /// 删除专题
        /// </summary>
        /// <param name="Normal_ZT"></param>
        /// <returns>string</returns>
        public string Delete(Normal_ZTEntity normal_ztEntity)
        {
            normal_ztEntity.DataTable_Action = DataTableAction.Delete;
            Normal_ZT bll = new Normal_ZT();
            if (bll.InsertUpdateDelete(normal_ztEntity) > 0)
            {
                  return "";
            }
            else
            {
                return "失败";
            }
        }

        /// <summary>
        /// 批量删专题
        /// </summary>
        /// <param name="idList">删除id列表  2_8_9_45</param>
        /// <returns>string</returns>
        public string DeleteList(string idList)
        {
            string[] list =Utils.SplitString(idList,"_");
            string strDel=Utils.ArrayToString(list,",",false);
            Normal_ZT bll = new Normal_ZT();
            if (bll.DelList(strDel) > 0)
            {
                 return "";
            }
            else
            {
                return "失败";
            }
        }

        /// <summary>
        /// 返回单个专题
        /// </summary>
        /// <param name="id"></param>
        /// <returns>Normal_ZTEntity</returns>
        public Normal_ZTEntity Look(int id)
        {
            Normal_ZT bll = new Normal_ZT();
            return bll.Disp(id);
        }
    }
}
